////////////////////////////////
// 前轮驱动
////////////////////////////////
var wheelFL:Transform;
var wheelFR:Transform;
var wheelRL:Transform;
var wheelRR:Transform;

var xRotSpeed:float = 20;
var maxYRotAngel:float = 30;

private var yAngle:float;

function Start(){
	
}
function Update () {
	var v:float = Input.GetAxis("Vertical");
	var h:float = Input.GetAxis("Horizontal");

	//绕自身x轴旋转. 
	wheelFL.Rotate(Vector3.right * v * xRotSpeed);
	wheelFR.Rotate(Vector3.right * v * xRotSpeed);
	wheelRL.Rotate(Vector3.right * v * xRotSpeed);
	wheelRR.Rotate(Vector3.right * v * xRotSpeed);
	if(v != 0 && h == 0){
		//前轮绕全局y轴,旋转恢复到0
		if(yAngle > 0){
			h = yAngle * 0.4;
			yAngle -= h;
		}
	}else{
		yAngle += h;
	}
	//绕全局y轴旋转.
	wheelFL.RotateAround(wheelFL.position,Vector3.up,h);
	wheelFR.RotateAround(wheelFR.position,Vector3.up,h);
}
